<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                <LINK rel="stylesheet" type="text/css" href="commun_styles.css"/>
            <title>Personnel</title>
        </head>
        <body>
            <h:form id="formpersonnel">
                <a4j:include viewId="entete.jsp"/>
                <a4j:include viewId="menu.jsp"/>
                <h:inputHidden value="#{PersonnelBean.init}"/>
                <rich:spacer height="50px"/>
                <center>
                    <rich:tabPanel style="width:50px;">
                    <rich:tab label="Personnel">
                    <h:outputText id="infomsg" value="#{PersonnelBean.message}" styleClass="valid_message"/>
                    <h:panelGrid width="450px" columns="1">
                        <rich:panel id="tablepanel" header="Liste personnel" >
                        <rich:dataTable
                        onRowMouseOver="this.style.backgroundColor='#B5CEFD'" binding="#{PersonnelBean.dataTable}"
                            onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'"
                            onRowClick="this.style.backgroundColor='#F1F1F1'"
                            rows="8" width="100%" id="tbl" value="#{PersonnelBean.person_list}" var="pers">
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="Nom"/>
                            </f:facet>
                            <h:outputText value="#{pers.persNom}" />
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="Prénom"/>
                            </f:facet>
                            <h:outputText value="#{pers.persPrenom}" />
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="Login"/>
                            </f:facet>
                            <h:outputText value="#{pers.persLogin}" />
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="Droit"/>
                            </f:facet>
                            <h:outputText value="#{pers.persDroit}" />
                        </rich:column>
                        <rich:column style="text-align:center">
                            <f:facet name="header">
                                <h:outputText value="Modifier"/>
                            </f:facet>
                            <a4j:commandLink action="#{PersonnelBean.modifierLigne}" reRender="infomsg,tablepanel,panelinfo,crud_panel" >
                                <h:graphicImage style="border:0" url="/images/Modify.gif" />
                            </a4j:commandLink>
                        </rich:column>
                        <rich:column style="text-align:center">
                            <f:facet name="header">
                                <h:outputText value="Supprimer"/>
                            </f:facet>
                            <a4j:commandLink ajaxSingle="true" action="#{PersonnelBean.supprimer}"
                            reRender="infomsg,tablepanel,panelinfo,crud_panel">
                                <h:graphicImage style="border:0" url="/images/Delete.gif"/>
                            </a4j:commandLink>
                        </rich:column>
                        <f:facet name="footer">
                            <rich:datascroller/>
                        </f:facet>
                        </rich:dataTable>
                    </rich:panel>
                    <rich:panel id="panelinfo" header="Informations générales" >
                        <h:panelGrid columns="2" width="350" >
                            <h:outputText value="Nom : " />
                            <h:inputText id="nompers" value="#{PersonnelBean.pers.persNom}"
                            size="25" maxlength="30" disabled="#{PersonnelBean.etat}"></h:inputText>

                            <h:outputText value="Prenom : " />
                            <h:inputText id="prepers" value="#{PersonnelBean.pers.persPrenom}"
                            size="25" maxlength="30" disabled="#{PersonnelBean.etat}"></h:inputText>

                            <h:outputText value="Login : " />
                            <h:inputText id="logpers" value="#{PersonnelBean.pers.persLogin}"
                            size="25" maxlength="50" disabled="#{PersonnelBean.etat}"></h:inputText>

                            <h:outputText value="Password : " />
                            <h:inputSecret id="pwdpers" value="#{PersonnelBean.pers.persPassword}"
                            size="25" maxlength="50" disabled="#{PersonnelBean.etat}"></h:inputSecret>

                            <h:outputText value="Droit : " />
                            <h:selectOneRadio id="drpers" value="#{PersonnelBean.pers.persDroit}" disabled="#{PersonnelBean.etat}">
                                <f:selectItem itemLabel="Utilisateur" itemValue="user" />
                                <f:selectItem itemLabel="Administrateur" itemValue="admin" />
                            </h:selectOneRadio>

                            <h:outputText value="Service : " />
                            <rich:comboBox id="servpers" disabled="#{PersonnelBean.etat}" defaultLabel="Entrez une valeur"
                                suggestionValues="#{PersonnelBean.service_list}"
                                value="#{PersonnelBean.current_service}" ></rich:comboBox>
                        </h:panelGrid>
                    </rich:panel>
                    </h:panelGrid>
                    <h:panelGrid id="crud_panel" columns="5">
                        <a4j:commandButton action="#{PersonnelBean.viderChamps}" id="nouvpers" value="Nouveau" ajaxSingle="true"
                            style="width:85px" disabled="#{PersonnelBean.invetat}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                        <a4j:commandButton id="modifpers" value="Modifier" action="#{PersonnelBean.modifier}" ajaxSingle="true"
                            style="width:85px" reRender="infomsg,tablepanel,panelinfo,crud_panel" disabled="#{PersonnelBean.invetat}"/>
                        <a4j:commandButton id="suppppers" value="Supprimer" ajaxSingle="true" action="#{PersonnelBean.supprimer}"
                            style="width:85px" disabled="#{PersonnelBean.invetat}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                        <a4j:commandButton id="validpers" value="Valider" style="width:85px" disabled="#{PersonnelBean.etat}"
                            reRender="infomsg,tablepanel,panelinfo,crud_panel" action="#{PersonnelBean.create}"/>
                        <a4j:commandButton id="annulpers" value="Annuler" style="width:85px" action="#{PersonnelBean.annuler}"
                            reRender="infomsg,tablepanel,panelinfo,crud_panel" disabled="#{PersonnelBean.etat}" ajaxSingle="true"/>
                    </h:panelGrid>
                    </rich:tab>
                    </rich:tabPanel>
                </center>
            </h:form>
        </body>
    </html>
</f:view>